package com.neusoft.cmsprojects.action;
 
import java.io.File;
import java.io.IOException;

import com.neusoft.cmsprojects.util.PictuerUploadDeleteUtil;

 
 

public class UploadAction extends SelfActionSupport {
 
    private static final long serialVersionUID = 1L;
    private File file_upload;// 上传文件
    private String uploadContentType;// 上传文件类型的属性
    private String uploadFileName;// 上传文件名
    private String savePath;// 上传路径（struts.xml 中配置的参数）
 
    private String message = "";
 
    //上传文件
    public String upload() throws IOException {
    	/*System.out.println("fbd");
    	String fileName = PictuerUploadDeleteUtil.uploadPicture(this.file_upload);
    	System.out.println(fileName);*/
    	
    	
   	System.out.println("gwhwgw");
    	System.out.println(uploadContentType);
    	System.out.println(file_upload);
    	//System.out.println(getServerPath());
        File targetFile = new File(getServerPath());
		if (!targetFile.exists()) {
		    targetFile.mkdirs();
		    System.out.println("gfs");
		}
		targetFile = new File(targetFile, getUploadFileName());
		/*boolean b = FileUtil.copyPaste(getUpload(), targetFile);
		if (b)
		    message = "文件上传成功，文件名为：" + uploadFileName + "。";
		else
		    message = "文件上传失败，文件名为：" + uploadFileName + "。";
      } catch (Exception e) {
		// TODO: handle exception
		e.printStackTrace();
      }*/
      return "success";
    }
 
   
 
    /**
	 * @return the file_upload
	 */
	public File getFile_upload() {
		return file_upload;
	}



	/**
	 * @param file_upload the file_upload to set
	 */
	public void setFile_upload(File file_upload) {
		this.file_upload = file_upload;
	}



	/**
	 * @return the serialversionuid
	 */
	public static long getSerialversionuid() {
		return serialVersionUID;
	}



	public String getUploadContentType() {
        return uploadContentType;
    }
 
    public void setUploadContentType(String uploadContentType) {
        this.uploadContentType = uploadContentType;
    }
 
    public String getUploadFileName() {
        return uploadFileName;
    }
 
    public void setUploadFileName(String uploadFileName) {
        this.uploadFileName = uploadFileName;
    }
 
    public String getSavePath() {
        return savePath;
    }
 
    public void setSavePath(String savePath) {
        this.savePath = savePath;
    }
 
    public String getMessage() {
        return message;
    }
 
    public void setMessage(String message) {
        this.message = message;
    }
 
}